<template>
    <div>
        <button @click="reqByPostParam">POST and URLSearchParams</button>
    </div>
</template>
<script>
import request from '@/utils/request';

export default {
    name: 'CaptchaComponent',
    data() {
        return {
            msg: 'Hello World'
        }
    },
    methods: {
        reqByPostParam() {
            const params = new URLSearchParams();
            params.append('name', 'John');
            params.append('age', 30);
            request.post('/axios/post/params/v1',params,{
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                }
            })
            .then(response => {
                console.log(response.data);
            }).catch(error => {
                console.error('Error:', error);
            });
        }
    }
}
</script>